package org.mimizet;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * User: Admin
 * Date: 29.08.11
 * Time: 13:41
 */
public class IteratorConverter implements Converter<Iterator, ArrayList> {
    public ConversionResult<Iterator, ArrayList> from(Iterator iterator){
        ArrayList arrayList = new ArrayList();

        while (iterator.hasNext()) {
            arrayList.add(iterator.next());
        }

        return new ConversionResult<Iterator, ArrayList>(arrayList.iterator(), arrayList);
    }

    public Iterator to(ArrayList list){
        return list.iterator();
    }
}
